#!/usr/bin/env python
import os.path
import tornado
import tornado.web
import tornado.wsgi
from tornado.ioloop import IOLoop
from tornado.httpserver import HTTPServer
import tornado.options
from config.routers import routers



settings = {
    "static_path" : os.path.join(os.path.dirname(__file__), "static"), 
    "template_path": os.path.join(os.path.dirname(__file__), "templates"),
    "debug": True,

}



def main():
    #wsgiref.handlers.CGIHandler().run(application)

    tornado.options.parse_command_line()
    application = tornado.web.Application(routers,**settings)
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(8888)
    IOLoop.instance().start()



if __name__ == "__main__":
    main()
